<html>
<head>
<title>Quicktime and Rococoa</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />           
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="rococoa.css" title="Default" />
</head>
<body>
<h1>Quicktime and Rococoa</h1>

<p>Rococoa was written to allow the use of the 
<a href="http://developer.apple.com/quicktime/qtkit.html">QTKit framework</a>
from Java. It's by no means finished, but it is functional.</p>

<p>The package <code>org.rococoa.quicktime</code> contains the work so far on
wrapping QTKit. An example of using the code to play a Quicktime Movie can be
found in <code>PlayMovieExample</code>.</p>

<pre class="block">
public class PlayMovieExample {

    static final File FILE = new File("testdata/DrWho.mov");

    static {
    	// load library
        @SuppressWarnings("unused")
        QTKit instance = QTKit.instance;
    }

    public static void main(String[] args) {
        QTMovieView movieView = QTMovieView.CLASS.create();
        movieView.setControllerVisible(true);
        movieView.setPreservesAspectRatio(true);

        MovieComponent component = new MovieComponent(movieView);
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(component);

        QTMovie movie = QTMovie.movieWithFile_error(FILE.getPath(), null);
        movieView.setMovie(movie);                
        movie.gotoBeginning();
        frame.pack();
        frame.setVisible(true);
    }

}
</pre>

<p><code>QTMovieTest</code> gives other examples.</p>

<p>One of the complications involved in using QTKit from Java is that all access
to QTKit must be on the Cocoa event thread, which is not the same as the 
AWT event thread. The <code>QTMovieView</code> and <code>QTMovie</code> classes are
annotated with <code>@RunOnMainThread</code> - Rococoa dispatches 
all method calls to such classes on the Cocoa event thread. If you plan to extend
the QTKit coverage your classes may need to be similarly annotated.</p>

<p>You may notice the absence of calls to <code>Foundation.createPool()</code>
in the code above. I'm still trying to get my head around this. Because the method
calls are all dispatched on the Cocoa event thread, and Cocoa conveniently creates
an autorelease pool for event handling code, the calls themselves are in the
context of a pool. I don't believe that this is the case for parameters that you
pass in though, so bear with my while I think it through.</p> 
</body>
</html>